package Operation;

import Book.Book;
import Book.Bookshelf;

import java.util.Scanner;

public class FindBook implements IOperation{
    @Override
    public void working(Bookshelf bookshelf) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入您所想要查找图书信息的图书名：");
        String bookName = scanner.nextLine();

        //遍历书架上的所有图书
        for (int i = 0; i < bookshelf.bookShelfNumber; i++) {
            Book book = bookshelf.books[i];
            if (bookName.equals(book.getName())) {
                System.out.println(book);
                return;
            }
        }
        System.out.println("对不起，书架上没有您所想要找的书！！！");
    }
}
